package com.sxt.test.java;

public class Queue2Stack {

    Queue queue1 = new Queue();
    Queue queue2 = new Queue();
    
    public void push(Object o) {
        queue1.add(o);
    }
    
    public Object pop() {
        Object o = null;
        while(queue1.length()>1) {
            queue2.add(queue1.poll());
        }
        if(queue1.length()==1) {
            o = queue1.poll();
            while(queue2.length()>0) {
                queue1.add(queue2.poll());
            }
        }
        
        return o;
    }
    
    public int length() {
        return queue1.length();
    }
    

}